﻿using AutoMapper;
using SE.PO.CInterface.DBProtocols.Areas;
using SE.PO.CInterface.DBProtocols.Devices;
using SE.PO.CInterface.DBProtocols.Rooms;
using SE.PO.CInterface.DBProtocols.Signals;
using SE.PO.CInterface.DBProtocols.Sites;
using SE.PO.CInterface.DBProtocols.SUs;

namespace SE.PO.CInterface.Web;

public class CInterfaceApplicationAutoMapperProfile : Profile
{
    public CInterfaceApplicationAutoMapperProfile()
    {
        #region Area

        CreateMap<Area, AreaDto>();

        CreateMap<CreateUpdateAreaDto, Area>();

        CreateMap<AreaDto, CreateUpdateAreaDto>();

        #endregion

        #region Site

        CreateMap<Site, SiteDto>()
            .ForMember("AreaName", opt => opt.MapFrom(src => src.Area.AreaName));

        CreateMap<CreateUpdateSiteDto, Site>();

        CreateMap<SiteDto, CreateUpdateSiteDto>();

        #endregion

        #region room

        CreateMap<Room, RoomDto>()
            .ForMember("SiteName", opt => opt.MapFrom(src => src.Site.SiteName));

        CreateMap<CreateUpdateRoomDto, Room>();

        CreateMap<RoomDto, CreateUpdateRoomDto>();

        #endregion

        #region Su

        CreateMap<SU, SUDto>()
            .ForMember("SiteName", opt => opt.MapFrom(src => src.Site.SiteName))
            .ForMember("RoomName", opt => opt.MapFrom(src => src.Room.RoomName));

        CreateMap<CreateUpdateSUDto, SU>();

        CreateMap<SUDto, CreateUpdateSUDto>();

        #endregion
        
        #region Device

        CreateMap<Device, DeviceDto>();

        CreateMap<CreateUpdateDeviceDto, Device>();

        CreateMap<DeviceDto, CreateUpdateDeviceDto>();
        
        // CreateMap<Equipment, EquipmentDto>();

        #endregion
        
        #region Signal

        CreateMap<Signal, SignalDto>();

        CreateMap<CreateUpdateSignalDto, Signal>();

        CreateMap<SignalDto, CreateUpdateSignalDto>();
        
        // CreateMap<Variable, VariableDto>();

        #endregion
    }
}